package com.example.demo1.wyy.controller;

import com.example.demo1.wyy.model.Girl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class TestController {

/*
     @Autowired
     private  GirlRepository girlRepository;
*/

    @GetMapping("hello/springBoot")
    public String helloSpringBoot() {

        return "this is test.class";

    }

    @RequestMapping(value="/hello/test/{id}",method=RequestMethod.GET)
    public String hello(@PathVariable("id") String id) {

        return id;

    }
    @RequestMapping(value="/hello/test")
    public Girl postTest(@RequestBody Girl girl ) {

        girl.setId(2);
        girl.setName("小李");
        girl.setAge(21);
        return girl;
    }
   /* @GetMapping("girl/findGirl")
    public List<Girl> findGirl() {

        return  girlRepository.findAll();

    }
    @PostMapping("girl/addGirl")
    public  String addGirl(@RequestBody Girl girl) throws  Exception {
        girlRepository.save(girl);
        return "success";
    }
    @PostMapping("girl/updateGirl")
    public  String updateGirl(@RequestBody Girl girl) throws  Exception {
        girlRepository.save(girl);
        return "success";
    }
    @GetMapping("girl/deleteGirl")
    public  String deleteGirl( @RequestParam("id") Integer id) throws  Exception {
        girlRepository.delete(id);
        return "success";
    }*/

    }
